package com.ruoyi.yljf.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.yljf.domain.vo.GoodsOrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.yljf.mapper.GoodsOrderMapper;
import com.ruoyi.yljf.domain.GoodsOrder;
import com.ruoyi.yljf.service.IGoodsOrderService;

import javax.annotation.Resource;

/**
 * 商品订单表Service业务层处理
 * 
 * @author TATAT
 * @date 2025-03-25
 */
@Service
public class GoodsOrderServiceImpl extends ServiceImpl<GoodsOrderMapper, GoodsOrder> implements IGoodsOrderService {
    @Resource
    private GoodsOrderMapper goodsOrderMapper;
    
    /**
     * 查询商品订单表列表
     * 
     * @param goodsOrder 商品订单表
     * @return 商品订单表
     */
    @Override
    public List<GoodsOrder> selectGoodsOrderList(GoodsOrder goodsOrder) {
    	LambdaQueryWrapper<GoodsOrder> queryWrapper = Wrappers.lambdaQuery();
        if (StringUtils.isNotEmpty(goodsOrder.getGoodsName())) {
			queryWrapper.like(GoodsOrder::getGoodsName, goodsOrder.getGoodsName());
		}
        if (StringUtils.isNotNull(goodsOrder.getUserId())) {
			queryWrapper.eq(GoodsOrder::getUserId, goodsOrder.getUserId());
		}
        if (StringUtils.isNotEmpty(goodsOrder.getAddress())) {
			queryWrapper.eq(GoodsOrder::getAddress, goodsOrder.getAddress());
		}
        if (StringUtils.isNotEmpty(goodsOrder.getUserPhone())) {
			queryWrapper.eq(GoodsOrder::getUserPhone, goodsOrder.getUserPhone());
		}
        if (StringUtils.isNotNull(goodsOrder.getStatu())) {
			queryWrapper.eq(GoodsOrder::getStatu, goodsOrder.getStatu());
		}
        return goodsOrderMapper.selectList(queryWrapper);
    }

    @Override
    public List<GoodsOrderVO> selectGoodsOrders(List<GoodsOrder> goodsOrders) {
        return goodsOrders.stream().map(item -> new GoodsOrderVO(item)).collect(Collectors.toList());
    }
}
